package unirest;

import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.JsonNode;
import com.mashape.unirest.http.Unirest;
import org.json.JSONArray;
import org.json.JSONObject;

public class Main {
    public static void main(String[] args) {
        try {
            Unirest.setTimeouts(1000 * 10, 1000 * 30);
            HttpResponse<JsonNode> response = Unirest
                    .get("https://devwealth.investmaster.cn/wealth/api/exchange/gbsExchangeRate")
                    .queryString("date", "2017-07-25")
                    .asJson();

            if (response.getStatus() == 200) {
                JSONObject json = response.getBody().getObject();
                JSONObject meta = json.getJSONObject("meta");
                int code = meta.getInt("code");

                if (code == 200) {
                    JSONArray data = json.getJSONArray("data");

                    System.out.println(data);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
